using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace Haidou.Wpf.Util.Converters;

public class ScaleConverter : IMultiValueConverter
{
	public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
	{
		double value = System.Convert.ToDouble(values[0]);
		double maximum = System.Convert.ToDouble(values[1]);

		return maximum < 1 ? 0d : (object)(value / maximum);
	}

	public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
	{
		return new[] { DependencyProperty.UnsetValue };
	}
}